//
//  GzipTEST.m
//  YuchBox
//
//  Created by Ivan on 11-10-11.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "GzipTEST.h"

@implementation GzipTEST

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }
    
    return self;
}

+ (void)TEST_beginEnable:(Boolean)enable;
{
    if (!enable) return;
    [GzipTEST TEST_deflate2];
}

+ (void)TEST_deflate2
{
//    NSString *in = [NSString stringWithFormat: @"ABCDEFG"];
//    UInt8 out[100];
//    uLong inlen = in.length;

//    bzero(out, 100);
//    [Gzip gzipDeflate2WithDest:out destLen:100 outDestLen:&outlen source:(UInt8 *)[in UTF8String] sourceLen:inlen];
//    //NSLog(@"length = %d\n", outlen);
//    [GzipTEST dumpdata:(UInt8*)[in UTF8String] len:inlen];
//    [GzipTEST dumpdata:out len:outlen];
//    

    // segment to two part
//    
//    bzero(out, 100);
//    [Gzip gzipDeflate2WithDest:out destLen:100 outDestLen:(uLong *)&outlen source:(UInt8 *)[in UTF8String] sourceLen:inlen/2];
//    [GzipTEST dumpdata:(UInt8 *)[in UTF8String] len:inlen/2];
//    [GzipTEST dumpdata:out len:outlen];
//    
////    NSInteger outlen2 = 0;
//    bzero(out, 100);
//    [Gzip gzipDeflate2WithDest:out destLen:100 outDestLen:(uLong *)&outlen source:(UInt8 *)[in UTF8String]+inlen/2 sourceLen:inlen/2];
//    [GzipTEST dumpdata:(UInt8 *)[in UTF8String]+inlen/2 len:inlen/2];
//    [GzipTEST dumpdata:out len:outlen];
//    
    // Gzip NSDATA
//    bzero(out, 100);
//    TTLOG_ERROR(@"\n/////////////");
//    //[Gzip gzipCompress:out destLen:100 outDestLen:&outlen source:(UInt8*)[in UTF8String] sourceLen:inlen];
//    //[GzipTEST dumpdata:out len:outlen];
//    UInt8 test[26] = "ABCDEFGH";    
//    uLongf outlen;// = 0;
//    //NSMutableData *out = [NSMutableData dataWithLength:26];
//    UInt8 out[1000];// = (UInt8*)malloc(100);
//    
//    bzero(out, 1000);
//    int ret2 = compress2(out, &outlen, test, 26, Z_BEST_SPEED);
//    
//    if (Z_OK != ret2) {
//        NSLog(@"deflate failed %d", ret2);
//    }
//    [GzipTEST dumpdata:out len:outlen];
    
//    TTLOG_ERROR(@"\n/////////////");
//    int x = 1;
//    TTLOG_ERROR_V(@"haha %d", x);
//    
//   
//    uLong inlen = 20;
//    NSInteger       gzipBufLen = 20;
//    uLong           outlen =0;
//    UInt8 out2[100];
//    bzero(out2, 100);
//    
//    //NSMutableData   *gzipBuffer = [NSMutableData dataWithLength:gzipBufLen];
//    
//    NSString *in = [NSString stringWithFormat: @"ABCDEFG"];
//    inlen = 7;
   // [Gzip gzipDeflate2WithDestData:gzipBuffer source:(UInt8 *)[in UTF8String] sourceLen:inlen];
  //  NSInteger outGzipBufLen = *((NSInteger *)[gzipBuffer bytes]);
   // [GzipTEST dumpdata:(UInt8 *)[gzipBuffer bytes] len:outGzipBufLen+GZIP_HEADER_LENGTH];
    
    
//    [Gzip gzipDeflate2WithDest:out2 destLen:100 outDestLen:&outlen source:(UInt8 *)[in UTF8String] sourceLen:inlen];
//    [GzipTEST dumpdata:out2 len:outlen];

    
//    
//    UInt8 in2[27]= {0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 0, 0x73, 0x74, 0x72, 0x76, 0x71, 0x75, 0x73, 0x7, 0, 0xbc, 0x94, 0x6f, 0xe, 0x7, 0, 0, 0};
//    gzipBufLen = 27;
//    [Gzip gzipInflate2WithDest:out2 destLen:100 outDestLen:&outlen source:in2 sourceLen:31];
//    [GzipTEST dumpdata:out2 len:outlen];
//    
    
    

    
}
@end
